Assoc Arrays
Volume Number: 7
Issue Number: 4
Column Tag: MacOOPs!
By Allen Stenger. Gardena, CA
Note: Source code files accompanying article are located on MacTech CD-ROM orsource code disks.
Associative arrays are arrays that are indexed by something other than integers.
This article shows a board-game--playing program that indexes an array by the
current board position to get the next move.
Several languages have associative arrays built into them, under various names:
SNOBOL4 (tables), LISP (association lists), REXX (no special name - all arrays can be
indexed by numbers or strings or both), Smalltalk (Dictionaries), and AWK
(associative arrays). Most of these allow indexing only by strings, although Smalltalk
allows any type or combination of types of objects. (Hardware implementations of
associative arrays are called associative memories or content-addressable memories.
For example, cache memories usually use a small associative memory to determine